import std.stdio;
import TASK =  std.parallelism;
import std.datetime;
import std.file;

void taskFun(int hh)
{
    writeln("task num is :", hh, " \t\t time: ",Clock.currStdTime() / 10000);
    scope(exit) writeln("exit num is :", hh, " \t\t time: ",Clock.currStdTime()/ 10000);
    long tm = Clock.currStdTime();
    do {
        long ts = Clock.currStdTime();
        if( (ts - tm) > (10000 * 200)) { //暂停200ms
            tm = -1;
        }
    } while (tm > 0);
}



void main()
{
    auto pool = new TASK.TaskPool(2);

    foreach(int i; 0..100000){
        auto t = TASK.task!taskFun(i);
        pool.put(t);
    }
    
    bool run = true;
    while(run){}
}
